<?php
require 'dbcon.php';
$id=  isset($_GET['id'])?$_GET['id']:0;
if (empty($_POST)){
$sp=$db->query("select * from tb_note where id='{$id}'");
$rows=$sp->fetch_array();
require 'index.php';
}  else {
$name=$_POST['name'];
$date=$_POST['date'];
$message=$_POST['message'];
$sp="update tb_note set name='$name',date='$date',message='$message' where id='$id'";
$rs=$db->query($sp);
if($rs){
   echo '<script anguage="javascript">';
    echo 'alert("成功了！");';
    echo 'window.location.href="index.php"';
    echo '</script>';
}else{
    echo '<script anguage="javascript">';
    echo 'alert("失败了！");';
    echo 'window.location.href="index.php"';
    echo '</script>';
}
}
$db->close();